#
# Mulle programming board.
#
# The Mulle programming board uses a FTDI FT2232H chip for USB UART and JTAG
# combined functionality.
#

# Reduce this if you are having problems with losing connection to the Mulle
adapter_khz 1000

# JTAG interface configuration

interface ftdi
#ftdi_device_desc "MP"
ftdi_vid_pid 0x0403 0x6010
#FTDI_SERIAL

ftdi_channel 1
ftdi_layout_init 0x0008 0x005b

#GDB_PORT
tcl_port 0
telnet_port 0

# These are the pins that are used for SRST and TRST. Note that the Mulle
# programming board inverts the reset signal between the FTDI chip and the MCU,
# so we need to use -ndata here to tell OpenOCD that the signals are active HIGH.
ftdi_layout_signal nTRST -ndata 0x0010
ftdi_layout_signal nSRST -ndata 0x0040

# In the eyes of OpenOCD, the reset signal is push-pull, because of the hardware
# design however, it is actually open drain.
# The trst pin can only be used if the MCU has been configured by setting the
# correct pin multiplexing function on the TRST pin (PTA5).
# If you have configured the TRST pin correctly you can change srst_only to
# trst_and_srst
reset_config srst_only srst_push_pull srst_gates_jtag

# MCU
gdb_memory_map enable
gdb_flash_program enable

source [find target/k60.cfg]

#
# Bank definition for the 'program flash' (instructions and/or data)
#
flash bank $_CHIPNAME.pflash.0 kinetis 0x00000000 0x20000 0 4 $_TARGETNAME
flash bank $_CHIPNAME.pflash.1 kinetis 0x00020000 0x20000 0 4 $_TARGETNAME

# The following section makes new gdb connections cause the MCU to do a system
# reset, in order to be in a known state.
# Comment this out in order to be able to debug an already started program.
$_TARGETNAME configure -event gdb-attach {
    echo "Resetting because of gdb-attach event..."
    # To make flash probe and gdb load to flash work we need a reset init.
    reset init
}

